package cn.sytton.taffecloud.common.model.file;

import cn.sytton.taffecloud.common.model.base.FieldEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;

import javax.validation.constraints.NotNull;
import java.util.UUID;

/**
 * 文件表entity sys_file
 *
 * @author skyrock
 */
@EqualsAndHashCode(callSuper = true)
@Data
@NoArgsConstructor
public class FileEntity extends FieldEntity {

    public FileEntity(String bucketName, String objectName, String originName, String suffix, long size, String url, String publicUrl) {
        this.fileId = UUID.randomUUID().toString();
        this.bucketName = bucketName;
        this.objectName = objectName;
        this.originName = originName;
        this.suffix = suffix;
        this.size = size;
        this.url = url;
        this.publicUrl = publicUrl;
    }

    public FileEntity(String bucketName, String objectName, long size) {
        this.bucketName = bucketName;
        this.objectName = objectName;
        this.size = size;
    }

    @NotNull(message = "文件ID不能为空")
    private String fileId;    // 文件ID 

    @NotNull(message = "文件本名不能为空")
    private String originName;    // 文件本名 

    @NotNull(message = "minio对象名不能为空")
    private String objectName;    // minio对象名 

    @NotNull(message = "存储桶不能为空")
    private String bucketName;    // 存储桶 

    private long size;    // 文件大小 

    private String suffix;    // 文件扩展名 

    //-----以下是关联属性-----
    private String url;
    private String publicUrl;
}
